﻿<UserControl x:Class="GemGui.EnvironmentControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:commands="clr-namespace:GemGui.Commands"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"
             Height="{Binding Height, ElementName=StkContainer}"
             Width="{Binding Width, ElementName=StkContainer}">
  <UserControl.Resources>
    <commands:EditCommandParametersConverter x:Key="EditCommandParametersConverter" />
  </UserControl.Resources>

  <StackPanel Name="StkContainer">
    <StackPanel Orientation="Horizontal">
      <CheckBox ToolTip="Check to include on quick-view" IsChecked="{Binding IsOnQuickView}" />
      <TextBlock Margin="5,0,0,0" Text="{Binding Info}" Visibility="{Binding IsInfoVisible}">
        <TextBlock.InputBindings>
          <MouseBinding Command="{Binding Container.EditCustomItemCommand}" MouseAction="LeftClick">
            <MouseBinding.CommandParameter>
              <MultiBinding Converter="{StaticResource EditCommandParametersConverter}">
                <Binding Source="{x:Static commands:EditCommandModes.InvokeEditMode}" />
                <Binding />
                <Binding ElementName="TxtCustomInfo" />
              </MultiBinding>
            </MouseBinding.CommandParameter>
          </MouseBinding>
        </TextBlock.InputBindings>
      </TextBlock>
    </StackPanel>
    <TextBox Name="TxtCustomInfo"
            Text="{Binding FolderCustomInformation, UpdateSourceTrigger=PropertyChanged}"
            Visibility="{Binding IsCustomInfoVisible}">
      <TextBox.InputBindings>
        <KeyBinding Command="{Binding Container.EditCustomItemCommand}" Key="Escape">
          <KeyBinding.CommandParameter>
            <MultiBinding Converter="{StaticResource EditCommandParametersConverter}">
              <Binding Source="{x:Static commands:EditCommandModes.CancelEditMode}" />
              <Binding />
              <Binding ElementName="TxtCustomInfo" />
            </MultiBinding>
          </KeyBinding.CommandParameter>
        </KeyBinding>

        <KeyBinding Command="{Binding Container.EditCustomItemCommand}" Key="Enter">
          <KeyBinding.CommandParameter>
            <MultiBinding Converter="{StaticResource EditCommandParametersConverter}">
              <Binding Source="{x:Static commands:EditCommandModes.ApplyEdit}" />
              <Binding />
              <Binding ElementName="TxtCustomInfo" />
            </MultiBinding>
          </KeyBinding.CommandParameter>
        </KeyBinding>
      </TextBox.InputBindings>
    </TextBox>
  </StackPanel>
</UserControl>
